﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using MultiWindows.Codes;

namespace MultiWindows.Forms
{
    public partial class FormDateTime : Form
    {
        public FormDateTime()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Weather.WeatherWebService w = new Weather.WeatherWebService();
            //把webservice当做一个类来操作  
            string[] s = new string[23];//声明string数组存放返回结果  
            string city = "上海";//获得文本框录入的查询城市  
            s = w.getWeatherbyCityName(city);
            //以文本框内容为变量实现方法getWeatherbyCityName  
            if (s[8] == "")
            {
                MessageBox.Show("暂时不支持您查询的城市");
            }
            else
            {
                //pictureBox1.Image = Image.FromFile(@"d:\image\" + s[8] + "");
                foreach (string str in s)
                {
                    this.textBox1.Text += str + "\n";
                }

                //
                //this.textBox1.Text += s[1] + " " + s[6];
                //textBox1.Text = s[10];
            }  
        }

        private void FormDateTime_FormClosing(object sender, FormClosingEventArgs e)
        {
            ((FormMain)this.ParentForm).SaveWindowState(Window.DATETIME, this.Height, this.Width, this.Top, this.Left);
        }

        private void FormDateTime_Load(object sender, EventArgs e)
        {
            this.txtDate.Text = DateTime.Today.ToLongDateString();
            this.txtXQ.Text = DateTime.Now.DayOfWeek.ToString();
            this.txtTime.Text = DateTime.Now.ToLongTimeString();
        }

        private void timer_Tick(object sender, EventArgs e)
        {
            this.txtTime.Text = DateTime.Now.ToLongTimeString();
        }
    }
}
